Skip to content

test(consumer): per-method broker for RebalanceAtScaleIntegrationTest — fix CI flake#224

Merged
eschizoid merged 1 commit into
mainfrom
fix/rebalance-per-method-broker
Jul 3, 2026
Merged

test(consumer): per-method broker for RebalanceAtScaleIntegrationTest — fix CI flake#224
eschizoid merged 1 commit into
mainfrom
fix/rebalance-per-method-broker

Conversation

@eschizoid

Copy link
Copy Markdown
Owner

Problem

RebalanceAtScaleIntegrationTest is the only test failing on main CI. Across 3 failing runs (the #221-merge run + both attempts of the #218 upload-artifact run) the signature is identical:

RebalanceAtScaleIntegrationTest > atLeastOnceSurvivesCooperativeStickyRebalance()  FAILED
RebalanceAtScaleIntegrationTest > revokeRunsOnConsumerThreadUnderRealRebalance()   FAILED
    java.util.concurrent.ExecutionException at RebalanceAtScaleIntegrationTest.java:325
        Caused by: org.apache.kafka.common.errors.TimeoutException

Line 325 is send.get(30s) in the produceRecords() setup helper — the producer can't get acks. Always this one class, always at produce, always the later-ordered methods (midFlight passes).

Root cause

The class shared one static KafkaContainer across its three @Test methods. Each method creates its own 6-partition topic + consumer groups and never tears them down, so that state accumulates on the single broker until a later method's producer can't deliver within delivery.timeout.ms and fails at the produce step.

It's the only container test class heavy enough (3 methods × 6 partitions) to degrade its own broker this way — which is exactly why it's the only class that flakes. A runner-wide resource problem would scatter failures across the other five container classes; it doesn't (ruling out the "too many forks / not enough RAM" theory).

Not caused by the upload-artifact v4→v7 bump, and not by the kafka 4.3.1 client bump.

Fix

Make the @Container field non-static so JUnit's default per-method lifecycle starts a fresh broker per test, isolating them. A why-comment on the field documents this so it isn't "optimized" back to static.

  • Cost: ~2 extra broker startups (~40 s) for this one class.
  • Scope: touches only RebalanceAtScaleIntegrationTest; the five healthy container classes are untouched.

Verification

Testcontainers can't run locally (no Docker) — verified it compiles. CI is the confirmation; I'll re-run this branch a few times to confirm the rebalance tests stay green before merging.

…ker to fix CI flake

RebalanceAtScaleIntegrationTest was the only class failing on main CI (3 runs: the #221
merge run + both attempts of the #218 run). The signature was identical every time:
produce timed out at line 325 (send.get in the produceRecords setup helper) with
org.apache.kafka.common.errors.TimeoutException, always in this one class, for its
later-ordered methods (cooperativeSticky, revoke) while midFlight passed.

Root cause: the class shared ONE static KafkaContainer across its three @test methods,
each of which creates its own 6-partition topic + consumer groups and never tears them
down. That state accumulated on the single broker until a later method's producer could
not get acks within delivery.timeout.ms, failing at the produce step during setup. It is
the only container test class heavy enough (3 methods x 6 partitions) to degrade its own
broker this way, which is why it was the only one that flaked — a runner-wide resource
problem would have scattered failures across the other five container classes, and it did
not.

Fix: make the @container field non-static so JUnit's default per-method lifecycle starts a
fresh broker for each test, isolating them. Costs ~2 extra broker startups (~40s) for this
one class; leaves the five healthy container classes untouched.

Cannot run Testcontainers locally (no Docker); verified it compiles. CI is the confirmation
— will re-run the branch a few times to confirm the rebalance tests stay green.
@eschizoid

Copy link
Copy Markdown
Owner Author

@copilot please review

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown

@copilot please review

Reviewed the current patch and CI context for this change. No additional code changes are needed for this comment.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@0848910). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #224   +/-   ##
=======================================
  Coverage        ?   80.52%           
  Complexity      ?      794           
=======================================
  Files           ?       66           
  Lines           ?     2927           
  Branches        ?      372           
=======================================
  Hits            ?     2357           
  Misses          ?      411           
  Partials        ?      159           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@eschizoid eschizoid merged commit fcb6255 into main Jul 3, 2026
6 checks passed
@eschizoid eschizoid deleted the fix/rebalance-per-method-broker branch July 3, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants